package com.gym.controller;


import com.gym.client.StaffdbClient;
import com.gym.pojo.Employee;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@RestController
public class StaffdbController {
    @Resource
    private StaffdbClient staffdbClient;

    @RequestMapping("/login")
    public Employee login(String account,String password){
        return staffdbClient.login(account,password);
    }
    @RequestMapping("/selempid")
    public Employee selempid(HttpServletRequest request, int empId){
        Employee employee= (Employee) request.getSession().getAttribute("黄猴儿2");
        System.out.println(employee);
        return staffdbClient.selempid(empId);
    }
    @RequestMapping("/selectpwd")
    public Employee selectpwd(String account,String password){return staffdbClient.selectpwd(account,password);}
    @RequestMapping("/selaccount")
    public List<Employee> selaccount(String account){
        return staffdbClient.selaccount(account);
    }
    @RequestMapping("/selemp")
    public Map<String,Object> select(String empname, Integer page, Integer limit){
        return staffdbClient.select(empname,page,limit);
    }
    @RequestMapping("/insert")
    public boolean insert(Employee em)  {
        return staffdbClient.insert(em);
    }
    @RequestMapping("/update")
    public boolean update(Employee em){
        return staffdbClient.update(em);
    }
    @RequestMapping("/delete")
    public boolean delete(int empId){
        return staffdbClient.delete(empId);
    }
    @RequestMapping("/updatepwd")
    public boolean updatepwd(Employee em){return staffdbClient.updatepwd(em);}

}
